<template>
  <a-badge-ribbon :color="ribbonColor" :text="ribbonText">
    <div class="HotListPanel">
      <!-- 头部 -->
      <div class="HotListPanel-header">
        <img :src="logoUrl" alt="Logo" style="width: 24px; height: 24px; margin-right: 8px;"/>
        <span class="HotListPanel-title">{{ title }}</span>
        <span class="HotListPanel-update-time">（更新时间：{{ updateTime }}）</span>
      </div>


      <!-- 列表 -->
      <ul class="HotListPanel-list">
        <li
            v-for="(item, index) in data.slice(0, 10)"
            :key="index"
            class="HotListPanel-item"
        >
          <span class="HotListPanel-item-index">{{ index + 1 }}.&nbsp&nbsp</span>
          <span class="HotListPanel-item-title">{{ item.title }}</span>

          <span class="HotListPanel-item-heat">🔥 {{ item.heat }}</span>
        </li>
      </ul>

    </div>
  </a-badge-ribbon>
</template>

<script lang="ts" setup>
interface Props {
  ribbonText: string;
  ribbonColor: string;
  title: string;
  updateTime: string;
  data: { title: string; heat: string }[];
  logoUrl: string;
}

defineProps<Props>();
</script>

<style scoped>
/* 基础样式 */
.HotListPanel {
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 16px;
  position: relative; /* 用于定位右上角徽标 */
}

.HotListPanel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e0e0e0;
}

.HotListPanel-title {
  font-size: 18px;
  font-weight: bold;
}

.HotListPanel-update-time {
  color: #999;
  font-size: 14px;
  margin-right: 60px;

}

.HotListPanel-list {
  list-style-type: none;
  padding: 0;
  max-height: 350px; /* 设置最大高度，超出部分启用滚动 */
  overflow-y: auto; /* 启用垂直滚动 */
}

.HotListPanel-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  border-bottom: 1px solid #e0e0e0;
  padding-bottom: 12px;
}

.HotListPanel-item-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.HotListPanel-item-heat {
  color: #ff6700;
  font-size: 14px;
}

</style>
